package com.quad.innovators.salesease.service.impl.task;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.quad.innovators.salesease.mapper.tag.TagTaskMapper;
import com.quad.innovators.salesease.model.entity.tag.TagTask;
import com.quad.innovators.salesease.model.vo.task.TagTaskVO;
import com.quad.innovators.salesease.service.task.TagTaskService;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

import lombok.RequiredArgsConstructor;

/**
 * @author : shanshan.li
 * @createTime : 2024/12/10 23:01
 * @Version : 1.0 
 */
@Service
@RequiredArgsConstructor
public class TagTaskServiceImpl extends ServiceImpl<TagTaskMapper, TagTask> implements TagTaskService {
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean addTagTaskList(List<String> tagCodeList, String taskCode) {
        return this.saveBatch(tagCodeList.stream().map(model -> {
            TagTask tagTask = new TagTask();
            tagTask.setTaskDistributionCode(taskCode);
            tagTask.setTagCode(model);
            return tagTask;
        }).toList());
    }

    @Override
    public List<TagTaskVO> getTagNameByTaskCodeList(List<String> taskCodeList) {
        return this.baseMapper.getTagNameByTaskCodeList(taskCodeList);
    }
}
